﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C = System.Console;

namespace Edu.Console
{
    public static class Arrays
    {
        public static void Lesson()
        {
            WriteArrayInfo(Arrays.IntArray);
            WriteArrayInfo(Arrays.D2Array);
            WriteArrayInfo(Arrays.D3Array);
            WriteArrayInfo(Arrays.TArray);

            Arrays.TArray[0] = new int[5];
            WriteArrayInfo(Arrays.TArray);

            Arrays.TArray[0][0] = 20;
            WriteArrayInfo(Arrays.TArray);

            WriteArrayInfo(Arrays.T2Array);

            IEnumerable<int> ie = Arrays.IntArray;
            var enumerator = ie.GetEnumerator();
            enumerator.MoveNext();
            C.WriteLine("enum={0}", enumerator.Current);
            enumerator.MoveNext();
            C.WriteLine("enum={0}", enumerator.Current);
        }

        public static int[] IntArray = new[] { 1, 2, 3, 4, 5, 6, 7 };

        public static int[,] D2Array = new int[5, 6];

        public static int[, ,] D3Array = new int[5, 6, 10];

        public static int[][] TArray = new int[5][];

        public static int[][][] T2Array = new int[5][][];

        private static void WriteArrayInfo(System.Array a)
        {
            C.WriteLine("TArray type = {0}, Rank = {1}, Lenght = {2}, Is value type = {3}",
                   a.GetType().Name,
                   a.Rank,
                   a.Length,
                   a.GetType().IsValueType);
        }
    }
}
